/**
 * 注意点：
 *      1.如果注意路由懒加载，需要导入react提供的两个成员：lazy,Suspense
 *      2.lazy:函数，用于导入需要实现懒加载的组件，语法：lazy(()=>import((路径))
 *      3.Suspense：组件，用于渲染加载中的等待提示，用于渲染转圈圈，语法：<Suspense fallback={加载组件}></Suspense>,需要懒加载的路由规则都需要写入该组件
 *      4.加载组件是否可以使用lazy导入？不能，loading组件不能偷懒
 */

import React, { lazy, Suspense } from 'react'
import { Route, Switch, Redirect } from 'react-router-dom'
import Loading from '../component/Loading'

// 导入需要懒加载的组件
const Login = lazy(() => import('../views/login/Index'))
const Dashboard = lazy(() => import('../views/Dashboard'))
const Basicrouter = () => {
  return (
    <Suspense fallback={<Loading />}>
      <Switch>
        <Redirect from="/" to="/login" exact></Redirect>
        <Route path="/login" component={Login}/>
        <Route path="/dashboard" component={Dashboard}/>
      </Switch>
    </Suspense>
  )
}

export default Basicrouter
